package com.zgkj.Zip.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zgkj.Zip.form.Feeinfoall;
import com.zgkj.Zip.form.NoticeInfo;
import com.zgkj.Zip.form.NoticeListInf;
import com.zgkj.Zip.tools.DBUtil;
import com.zgkj.Zip.tools.DateUtil;

public class IniParaService {

	public void  instert(NoticeInfo NoticeInfo,NoticeListInf NoticeListInf) {
		DBUtil db = null;
		try {
			db = new DBUtil();
			String  examinername = "";
			String  department = "";
			String  phone = "";
			ArrayList<String> sqlList = new ArrayList<String>();
			String qryString = "select count(1) from BICPCFLOWTB where FAWENXLH = '"+NoticeListInf.getFawenxlh()+"'";
			int count = db.getNumber(qryString);
			System.out.println(qryString);
			System.out.println(count);
			if(count!=0){
				return;
			}
			if(NoticeInfo!=null){
				List<Feeinfoall> aList = NoticeInfo.getFee_info_all();
				for (Feeinfoall Feeinfoall : aList) {
					String insertFeeSqlString = " insert into BICWINFTB (CASEID, FEENAME, FEEAMT, ENDDATE,SHENQINGH,INSTDATE,INSTTIME)   " +
					" values (" +
					"'"+"',"+
					"'"+Feeinfoall.getFee_name()+"',"+
					"'"+Feeinfoall.getFee_amount()+"',"+
					"'"+NoticeInfo.getPay_deadline_date()+"',"+
					"'"+(NoticeListInf.getShenqingh()==null?"":NoticeListInf.getShenqingh())+"',"+
					"'"+DateUtil.getSystemDate()+"',"+
					"'"+DateUtil.getSystemTime()+"'"+
					")";
					sqlList.add(insertFeeSqlString);

				}
				examinername = NoticeInfo.getExaminer_name();
				department = NoticeInfo.getDepartment();

			}
			String insertSqlString = "insert into BICPCFLOWTB (SHENQINGH,CASEID, FAWENR, TONGZHISMC, " +
			"TONGZHISBM, ENDDATE, TONGZHISID, FAWENXLH,EXAMINERNAME, DEPARTMENT, PHONE,INSTDATE,INSTTIME) " +
			"values (" +
			"'"+(NoticeListInf.getShenqingh()==null?"":NoticeListInf.getShenqingh())+"',"+
			"'"+(NoticeListInf.getNeibubh()==null?"":NoticeListInf.getNeibubh())+"',"+
			"'"+(NoticeListInf.getFawenr()==null?"":NoticeListInf.getFawenr())+"',"+
			"'"+(NoticeListInf.getTongzhismc()==null?"":NoticeListInf.getTongzhismc())+"',"+

			"'"+(NoticeListInf.getTongzhisbm()==null?"":NoticeListInf.getTongzhisbm())+"',"+
			"'"+""+"',"+
			"'"+ (NoticeListInf.getTongzhisid()==null?"":NoticeListInf.getTongzhisid())+"',"+
			"'"+ (NoticeListInf.getFawenxlh()==null?"":NoticeListInf.getFawenxlh())+"',"+
			"'"+ examinername+"',"+
			"'"+ department+"',"+
			"'"+ phone +"',"+
			"'"+DateUtil.getSystemDate()+"',"+
			"'"+DateUtil.getSystemTime()+"'"
			+ ")";
			sqlList.add(insertSqlString);
			db.addBatch(sqlList);
			db.executeBatch();
			System.out.println("处理完成……");

		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			db.close();
		}

	}
}
